package com.bear.sgg.springboot_06_web.ThreeComponent;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpFilter;
import java.io.IOException;

/**
 * @ClassNmae MyFilter
 * @Description 自定义filter（用于过滤请求，相当于spring mvc中的Interceptor）
 * @Author bear
 * @Date 2020/3/12 0012 下午 3:15
 */
public class MyFilter extends HttpFilter {

    @Override
    public void init() throws ServletException {
        super.init();
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("请求被拦截了");
        super.doFilter(request, response, chain);
    }

    @Override
    public void destroy() {
        
    }
}
